cmake_minimum_required(VERSION 3.2)
project(CPHMSensor)
set(CMAKE_CXX_STANDARD 17)
file(GLOB filecode "capture/*.hpp")
set(code ${code} ${filecode})
file(GLOB filecode "alg/*.h")
set(code ${code} ${filecode})
file(GLOB filecode "sensor/*.hpp")
set(code ${code} ${filecode})
if(USE_IOTDB)
    aux_source_directory(iotdb code)
endif()
aux_source_directory(data code)
list(REMOVE_ITEM code data/database_td.cpp)
aux_source_directory(cmd code)
if(Qt)
if(WIN32)
    find_package(Qt6 COMPONENTS REQUIRED Core Gui Widgets Network PATHS D:/Tools/Qt/6.6.0/msvc2019_64/lib/cmake)
else()
    find_package(Qt6 COMPONENTS REQUIRED Core Gui Widgets Network PATHS /root/sda/qt/6.8.0/gcc_arm64/lib/cmake)
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(QT_UIC_EXECUTABLE /usr/lib/x86_64-linux-gnu/qt5/bin/uic)
endif()

set(code ${code} main.cpp)
if(WIN32)
include_directories(
    .
    C:/TDengine/include
    D:/Opensource/drogon/lib/inc
    D:/Opensource/drogon/trantor
    D:/Opensource/drogon/orm_lib/inc
    D:/Opensource/drogon/nosql_lib/redis/inc
    D:/Opensource/drogon/build/exports
    D:/Opensource/drogon/build/trantor/exports
    D:/Opensource/jsoncpp/include
    D:/HTCK/2024/armadillo-12.6.6/include
    D:/Opensource/amqpcpp/include
    D:/Opensource/amqpcpp/rabbitmq-c/include
    D:/Opensource/amqpcpp/build/rabbitmq-c/include
    D:/Opensource/mqtt_cpp/include

    D:/Opensource/openssl
    D:/Tools/Qt/6.6.0/msvc2019_64/include/QtMqtt
    D:/Opensource/boost_1_85_0
)
link_directories(
    C:/TDengine/driver
    D:/Opensource/drogon/build/Debug
    D:/Opensource/drogon/build/trantor/Debug
    D:/Opensource/jsoncpp/build/lib/Debug

    D:/Opensource/openssl
    D:/Tools/Qt/6.6.0/msvc2019_64/lib
    D:/Opensource/boost_1_85_0/stage/lib
    D:/Opensource/amqpcpp/build/Debug
    D:/Opensource/amqpcpp/build/rabbitmq-c/librabbitmq/Debug
)
set(OPENSSL_ROOT_DIR D:/Opensource/openssl)
set(ZLIB_INCLUDE_DIR D:/Opensource/zlib)
set(ZLIB_LIBRARY D:/Opensource/zlib/build/zlibstatic.lib)
else()
include_directories(
    .
    /root/sda/drogon/lib/inc
    /root/sda/drogon/trantor
    /root/sda/drogon/orm_lib/inc
    /root/sda/drogon/nosql_lib/redis/inc
    /root/sda/drogon/build/exports
    /root/sda/drogon/build/trantor/exports
    /usr/include/jsoncpp
    /root/sda/armadillo-12.6.6/include
    /root/sda/amqpcpp/include
    /root/sda/amqpcpp/rabbitmq-c/include
    /root/sda/amqpcpp/build/rabbitmq-c/include
    /root/sda/mqtt_cpp/include

    /root/sda/openssl
    /root/sda/boost_1_85_0
)
link_directories(
    /root/sda/drogon/build/
    /root/sda/drogon/build/trantor/
    /usr/lib/aarch64-linux-gnu

    /root/sda/openssl
    /root/sda/boost_1_85_0/stage/lib
    /root/sda/amqpcpp/build/
    /root/sda/amqpcpp/build/rabbitmq-c/librabbitmq/
)
endif()

add_definitions(-DBOOST_ASIO_STANDALONE -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
#add_definitions(-DTEST)
if(MSVC)
    add_compile_options(/EHa /utf-8 /bigobj /openmp)
else()
    add_compile_options(-fPIC -fexceptions -fexec-charset=UTF-8 -fopenmp)
endif()

find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
add_executable(CPHMSensor ${code})

if(Qt)
target_link_libraries(CPHMSensor Qt6::Core Qt6::Network)
endif()
if(WIN32)
target_link_libraries(CPHMSensor drogon trantor amqpcpp-static librabbitmq.4)
target_link_libraries(CPHMSensor libboost_locale-vc143-mt-gd-x64-1_85 libboost_log-vc143-mt-gd-x64-1_85)
target_link_libraries(CPHMSensor OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB jsoncpp_static rpcrt4.lib)
target_link_libraries(CPHMSensor taos)
else()
target_link_libraries(CPHMSensor drogon trantor amqpcpp-static rabbitmq)
target_link_libraries(CPHMSensor boost_locale boost_log boost_thread boost_filesystem boost_system)
target_link_libraries(CPHMSensor OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB jsoncpp uuid pthread dl)
endif()
